﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Camping_Project.Forms
{
    public partial class FormCreationClient : Form
    {
        public FormCreationClient()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void FormCreationClient_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (tbNom.Text == "" || tbPrenom.Text == "" || tbDateNaissance.Text == "" || tbAdresse.Text == "" || tbCodePostal.Text == "" || tbVille.Text == "" || tbPays.Text == "" || tbTelephone.Text == "" || tbEMail.Text == "")
                MessageBox.Show("Veuillez remplir tous les champs!", "Informations incomplètes", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            else
            {
                Camping_BDD bdd = new Camping_BDD();
                Client cl = new Client { Nom = tbNom.Text, Prenom = tbPrenom.Text, DateNaissance = DateTime.Parse(tbDateNaissance.Text), Adresse = tbAdresse.Text, CodePostal = tbCodePostal.Text, Ville = tbVille.Text, Pays = tbPays.Text, Telephone = tbTelephone.Text, Email = tbEMail.Text };
                bdd.Client.AddObject(cl);
                bdd.SaveChanges();

                MessageBox.Show("Le client " + tbNom.Text + " " + tbPrenom.Text + " a bien été ajouté", "Succes de l'opération", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
